package com.dts.evaluate.ui.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.widget.LinearLayout;

import com.dts.evaluate.R;

/**
 * Created by user on 2016/7/30.
 */
public class StrokeRightLinearLayout extends LinearLayout {
    private Paint paint;
    private int color = ContextCompat.getColor(getContext(), R.color.list_devider_color);

    public StrokeRightLinearLayout(Context context) {
        super(context);
        init(context);
    }

    public StrokeRightLinearLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public StrokeRightLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }
    private void init(Context context){
        paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(1);
    }

    @Override
    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        int width = getMeasuredWidth();
        int height = getMeasuredHeight();

        paint.setColor(color);
        canvas.drawLine(width,0,width,height,paint);
    }
}
